package com.example.concurrent.ExecutorService;

import java.util.concurrent.*;

/**
 * Created by Administrator on 2017/2/10 0010.
 */
public class submitCallableDemo {

    public static void main(String[] args) {


        ExecutorService executorService = Executors.newSingleThreadExecutor();

        try {
            Future future = executorService.submit(new Callable(){
                public Object call() throws Exception {
                    System.out.println("Asynchronous Callable");
                    return "Callable Result";
                }
            });
            System.out.println("future.get() = " + future.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }

        executorService.shutdown();

    }
}
